package fpt.edu.vn.action;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import fpt.edu.vn.dao.AddnewDao;
import fpt.edu.vn.dao.TopicsDao;
import fpt.edu.vn.model.Provinces;
import fpt.edu.vn.model.Statustopics;
import fpt.edu.vn.model.Topictypes;

/* 
 * AdminListTopicLoadAction.java 
 *  
 * 0.1
 * 
 * 10/15/2012 
 *  
 * Copyright notice 
 *  
 * Modification Logs: 
 *   DATE        AUTHOR      DESCRIPTION 
 *  -------------------------------------------------------- 
 *  15-Oct-2012  ThuongND    Create new 
 */
public class AdminLoadSystemAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	private String email;

	private String Username;

	private List<Provinces> lstProvince;
	private List<Topictypes> lstTopictypes;
	private List<Statustopics> lstStatustopics;
	private List<Object> lstTopics;
	private int totaltopic;
	private int totalUser;
	private int totalUserBanner;
	private int news_per_page;
	private AddnewDao addnewdao = new AddnewDao();
	private TopicsDao topicdao = new TopicsDao();
	// For SessionAware
	Map<String, Object> session;

	public String execute() {
		session = ActionContext.getContext().getSession();
		if (session.containsKey("userRoleIdss")) {
			email = (String) session.get("emailss");
			int isAdmin = (Integer) session.get("userRoleIdss");
			if (isAdmin == 1) {
				// get district
				this.lstProvince = addnewdao.getProvince();
				this.lstTopictypes = topicdao.topictype();
				this.lstStatustopics = topicdao.topicstatus();
				this.lstTopics = topicdao.listalltopic();
				this.totaltopic = topicdao.totalTopic().size();
				this.totalUser = topicdao.totalUser().size();
				this.totalUserBanner = topicdao.totalUserBaner().size();
				news_per_page =20;
				return SUCCESS;
			} 
		}
		return ERROR;

	}

	public Date getSysdate() {
		Date date = new Date();
		return date;
	}
	
	public String getStrDate() {
		String curdate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
				.format(Calendar.getInstance().getTime());
		return curdate;
	}
	
	public int getTotaltopic() {
		return totaltopic;
	}
	
	public int getTotalUser() {
		return totalUser;
	}

	public void setTotalUser(int totalUser) {
		this.totalUser = totalUser;
	}

	public int getTotalUserBanner() {
		return totalUserBanner;
	}

	public void setTotalUserBanner(int totalUserBanner) {
		this.totalUserBanner = totalUserBanner;
	}

	public void setTotaltopic(int totaltopic) {
		this.totaltopic = totaltopic;
	}

	public int getNews_per_page() {
		return news_per_page;
	}
	
	public void setNews_per_page(int news_per_page) {
		this.news_per_page = news_per_page;
	}

	public List<Statustopics> getLstStatustopics() {
		return lstStatustopics;
	}

	public void setLstStatustopics(List<Statustopics> lstStatustopics) {
		this.lstStatustopics = lstStatustopics;
	}

	public List<Topictypes> getLstTopictypes() {
		return lstTopictypes;
	}

	public void setLstTopictypes(List<Topictypes> lstTopictypes) {
		this.lstTopictypes = lstTopictypes;
	}

	public List<Object> getLstTopics() {
		return lstTopics;
	}

	public void setLstTopics(List<Object> lstTopics) {
		this.lstTopics = lstTopics;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return Username;
	}

	public void setUsername(String username) {
		Username = username;
	}

	public List<Provinces> getLstProvince() {
		return lstProvince;
	}

	public void setLstProvince(List<Provinces> lstProvince) {
		this.lstProvince = lstProvince;
	}
}
